package tests.suite.tests
{
	import com.gdcnano.nanoamp.media.sound.playlist.IPlaylist;
	import com.gdcnano.nanoamp.media.sound.playlist.XSPFPlaylist;
	
	import flexunit.framework.Assert;

	public class XSPFPlaylistTest
	{
		private static var XSPFXML:XML = 
							<playlist version="1" xmlns="http://xspf.org/ns/0/">
							
							    <!-- title of the playlist -->
							    <title>Sample playlist</title>
							
							    <!-- name of the author -->
							    <creator>marat gareev</creator>
							
							    <!-- homepage of the author -->
							    <info>http://example.com/</info>
			
							    <trackList>
							    <track>
							      <location>http://ru100379426/music/Compilations/Trance In Motion (vol.23)/01 Waiting (Original Mix).mp3</location>
							      <title>Waiting (Original Mix)</title>
							      <creator>Dash Berlin Feat. Emma Hewitt</creator>
							      <album>Trance In Motion (vol.23)</album>
							    </track>
							    <track>
							      <location>http://ru100379426/music/Compilations/Trance In Motion (vol.23)/02 You And I (Dash Berlin Mix).mp3</location>
							      <title>You And I (Dash Berlin Mix)</title>
							      <creator>Median</creator>
							      <album>Trance In Motion (vol.23)</album>
							    </track>
							    <track>
							      <location>http://ru100379426/music/Compilations/Trance In Motion (vol.23)/03 Spellbound (Original Mix).mp3</location>
							      <title>Spellbound (Original Mix)</title>
							      <creator>Tritonal Feat. Christina Soto</creator>
							      <album>Trance In Motion (vol.23)</album>
							    </track>
							  </trackList>
							</playlist>;
		
		// !IMPORTANT Should be the same as <title> element value in XSPFXML
		private static var PLAYLIST_NAME:String = "Sample playlist";
		
		// !IMPORTANT Should be equal to <track> elements count in <tracklist>
		private static var PLAYLIST_LENGTH:int = 3;
		
		private var _xspfPlaylist:IPlaylist;
		
		public function XSPFPlaylistTest()
		{
		}
		
		[Test]
		public function canCreateXSPFPlaylistFromXML():void
		{
			// Check that playlist is not initialized
			Assert.assertNull(_xspfPlaylist);
			// Create playlist from XML
			_xspfPlaylist = new XSPFPlaylist();
			_xspfPlaylist.setPlaylistData(XSPFXML);
			// Check playlist name
			Assert.assertEquals(_xspfPlaylist.playlistName, PLAYLIST_NAME);
			// Check tracks count
			Assert.assertEquals(_xspfPlaylist.tracklist.length, PLAYLIST_LENGTH);
		}
	}
}